package com.aree.caipiao.shsq.view;

import java.util.Map;

import com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao;
import com.aree.caipiao.shsq.dao.jdbc.ShuangSeQiuResultDao;
import com.aree.caipiao.shsq.service.impl.AnalizyServiceImpl;

/**
 * 控台视图
 * @author hp-pc
 *
 */
public class ConsoleView {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*IShuangSeQiuResultDao dao = new ShuangSeQiuResultDao();
		AnalizyServiceImpl service = new AnalizyServiceImpl();
		service.setShuangSeQiuResultDao(dao);
		Map<Integer, Integer> results = service.hezhiFenxi();
		int total = 0;
		int small = 0;
		int big = 0;
		for (Integer he : results.keySet()) {
			int count = results.get(he);
			total += count;
			if (he < 110.5) small += count;
			else big += count;
			//System.out.println(he + "\t" + count);
		}
		System.out.println("total:" + total + ",<110.5:" + small + ",>110.5:" + big);*/
		IShuangSeQiuResultDao dao = new ShuangSeQiuResultDao();
		AnalizyServiceImpl service = new AnalizyServiceImpl();
		service.setShuangSeQiuResultDao(dao);
		Map<Integer, Double> fenxiResults = service.standardHeZhiDispute();
		double q = 0;
		for (Integer he : fenxiResults.keySet()) {
			double g = fenxiResults.get(he);
			q += (he * g);
			//System.out.printf("%d \t %.2f", he, g*100);
			//System.out.println();
		}
		System.out.printf("和值期望是%.2f：", q);
		System.out.println();
		int total = new ShuangSeQiuResultDao().count();
		Map<Integer, Integer> result = service.hezhiFenxi();
		int sum = 0;
		for (Integer hezhi : result.keySet()) {
			int num = result.get(hezhi);
			sum += hezhi*num;
		}
		System.out.println("实际的均值:" + sum/total);
		/*LianHaoNumber lianhaoNumber = LianHaoNumber.THREE;
		ChooseChain lianhaoChain = new LianhaoChooseChain(lianhaoNumber);
		ChooseChain hezhiChain = new HezhiChooseChain(22, 48);
		hezhiChain.setNext(lianhaoChain);
		List<Integer> luckeNumbers = new ArrayList<Integer>();
		luckeNumbers.add(1);luckeNumbers.add(10);
		ChooseChain luckeyChain = new LuckeyNumberChooseChain(luckeNumbers);
		lianhaoChain.setNext(luckeyChain);
		ChooseChain randomChain = new RandomChooseChain(20);
		luckeyChain.setNext(randomChain);
		
		List<ShuangSeQiuNumbers> all = ShuangSeQiuUtil.generateAllNumbers();
		List<Integer> allIndexes = randomChain.filter(ShuangSeQiuUtil.generateAllNumbersIndexes());
		for (int index : allIndexes) {
			ShuangSeQiuNumbers n = all.get(index);
			System.out.println(n + "， 和值是：" + n.getHe());
		}
		System.out.println("共有：" + allIndexes.size() + "组合符合条件");*/
	}

}
